<?php
use Fox\Utilities;
use Fox\Note;

/**
 * This page display the message body.
 *
 * @author Xavier VILAIN
 * @package allocation
 */
$notid = Xview::instance()->val("notid");
use Fox\Html\TextArea;
try {
	$note = new Note($notid);
	$userid = User::current()->getId();
	$note->markAsRead($userid);
}
catch (Fox\Object\Exception\NotExist $e)
{
	Fox\Message::Errors($e->getMessage());
}
catch (Fox\Object\Exception\Save $e)
{
	Fox\Core\Errors::pushMessage($e);
}

$screen = new Fox\Html\Screen("E_NOTE");
if(!$screen->errors())
{
	$data = $note->getData();
	$uname = User::fullName($data['cname']);

	$bl_detail = new Fox\Html\Block("B_NOTE");

	if(!empty($uname))
	{
		$bl_detail->add(new Fox\Html\Input("email_from",false,$uname));
		$bl_detail->item("email_from")->printable(true);
	}
	$text = Utilities\Text::toHtml($data['body']);
	$bl_detail->add(new TextArea("message",false,$text,10,100));
	$bl_detail->item("message")->printable(true);
	$label = $bl_detail->item("message")->label();
	$bl_detail->item("message")->label("<b>".$label."</b>");

	$screen->add($bl_detail);
}
$popup = new Fox\Popup("P_NOTE_DETAIL",Msg(Fox::MSGCL,135),$screen,null,null,570);
echo $popup->Display();
